import {
  FileResultVO,
  checklmportOV,
  checklmportOVs,
  TaskInterimTargetPageQuery,
  TaskTargetTypeResultVO,
  UploadDetailById,
  UploadDetailByIdOV,
  UploadPdfResult,
  userUpload,
  TeseuserUpload,
  expirationTime,
  DefDictSaveVO,
  PingfenVO,
  DefDictSaveVOs,
  PingfenVOs,
  getAllCodeYearsReault,
  generateTaskCheckCodes,
  generateTaskCheckCodeResult,
  getTaskCheckCodeByYearAndTypeos,
  getTaskCheckCodeByYearAndTypeVO,
  getTaskFeatureContributeListos,
  getTaskFeatureContributeListVO,
  getAllFeatureContributeYearsReault,
  taskFeatureContributeOS,
  getTaskTemporaryWorkListVO,
  getTaskTemporaryWorkListos,
  getAllTaskTemporaryWorkYearsReault,
  taskTemporaryWorkMaterialOS,
  taskTemporaryWorkOS,
  taskTemporaryWorkputOS,
  getTaskNegativeItemListos,
  getTaskNegativeItemListVO,
  taskNegativeItemOS,
  taskNegativeItemputOS,
  getAllTaskNegativeItemYearsReault,
  getFinalResultByYearJXOS,
  getFinalResultByYearOS,
  getFinalResultByYearJXVO,
  getFinalResultByYeartVO,
} from './model/index';
import { PageParams, PageResult } from '/@/api/model/baseModel';
import { defHttp } from '/@/utils/http/axios';
import type { AxiosRequestConfig } from 'axios';
import qs from 'qs';
import type { AxiosProgressEvent } from 'axios';

import { UploadFileParams } from '/#/axios';
import { RequestEnum } from '/@/enums/httpEnum';
import { ServicePrefixEnum } from '/@/enums/commonEnum';
// import { MOCK_API_URL } from '/@/settings/siteSetting';
// const MODULAR = 'file';
export const Api = {
  // 导入
  importQimo: {
    url: `/taskTarget/importDetails`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  // 检测是已重复导入
  importQimoOr: {
    url: `/taskTarget/checkImport`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  // 表格查询
  Page: {
    // url: `/base/taskTarget/getYearTaskTargetOfTenant`,
    // url: `${ServicePrefixEnum.FILE}/taskTarget/getYearTaskTargetOfTenant`,
    url: `/taskTarget/getYearTaskTargetOfTenant`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  // 根据表格查找详情
  UploadgetDetailById: {
    url: `/taskTarget/getTaskTargetByTwoId`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  // 支撑材料上传
  upload: {
    url: `/file/anyone/upload`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  // 支撑材料上传确定
  NewUpload: {
    url: '/taskTargetMaterial',
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  del: {
    url: '/taskTargetMaterial',
    method: RequestEnum.DELETE,
  } as AxiosRequestConfig,

  expirationTime: {
    url: `/taskTargetMaterial/updateExpirationTime`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  taskInterimMark: {
    url: `/taskTargetMark`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  taskInterimMarkPUT: {
    url: `/taskTargetMark`,
    method: RequestEnum.PUT,
  } as AxiosRequestConfig,
  checkIsCommit: {
    url: `/taskTarget/checkIsCommit`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  commitConfirm: {
    url: `/taskTarget/commitConfirm`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  // 根据年份生成校验码类型
  generateTaskCheckCode: {
    url: `/taskCheckCode/generateTaskCheckCode`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  // 查询所有的校验码
  getAllCodeYears: {
    url: `/taskCheckCode/getAllCodeYears`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,

  // 查询生成二维码列表
  getTaskCheckCodeByYearAndType: {
    url: `/taskCheckCode/getTaskCheckCodeByYearAndType`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,

  // 查询特色贡献历史年份
  getAllFeatureContributeYears: {
    url: `/taskFeatureContribute/getAllFeatureContributeYears`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  // 查询特色贡献
  getTaskFeatureContributeList: {
    url: `/taskFeatureContribute/getTaskFeatureContributeList`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  // 新增特色贡献
  taskFeatureContribute: {
    url: `/taskFeatureContribute`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  // 修改特色贡献
  taskFeatureContributeput: {
    url: `/taskFeatureContribute`,
    method: RequestEnum.PUT,
  } as AxiosRequestConfig,
  // 上传文件的id
  TsUpload: {
    url: `/taskFeatureContributeMaterial`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  // 删除上传文件的id
  TsUploadDelete: {
    url: `/taskFeatureContributeMaterial`,
    method: RequestEnum.DELETE,
  } as AxiosRequestConfig,
  //下载特色贡献
  down: {
    url: `/taskFeatureContribute/anyTenant/downloadFile`,
    method: RequestEnum.GET,
    responseType: 'blob',
  } as AxiosRequestConfig,

  // 查询重大工作历史年份
  getAllTaskTemporaryWorkYears: {
    url: `/taskTemporaryWork/getAllTaskTemporaryWorkYears`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  // 查询重大工作
  getTaskTemporaryWorkList: {
    url: `/taskTemporaryWork/getTaskTemporaryWorkList`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  // 新增重大工作
  taskTemporaryWork: {
    url: `/taskTemporaryWork`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  // 修改重大工作
  taskTemporaryWorkput: {
    url: `/taskTemporaryWork`,
    method: RequestEnum.PUT,
  } as AxiosRequestConfig,
  // 上传重大工作文件的id
  taskTemporaryWorkMaterial: {
    url: `/taskTemporaryWorkMaterial`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  // 删除上传文件的id
  ZDUploadDelete: {
    url: `/taskTemporaryWorkMaterial`,
    method: RequestEnum.DELETE,
  } as AxiosRequestConfig,
  //下载临时重大
  downloadFile: {
    url: `/taskTemporaryWork/anyTenant/downloadFile`,
    method: RequestEnum.GET,
    responseType: 'blob',
  } as AxiosRequestConfig,

  // 查询负面清单历史年份
  getAllTaskNegativeItemYears: {
    url: `/taskNegativeItem/getAllTaskNegativeItemYears`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  // 查询年度负面清单
  getTaskNegativeItemList: {
    url: `/taskNegativeItem/getTaskNegativeItemList`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  // 新增负面清单
  taskNegativeItem: {
    url: `/taskNegativeItem`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  // 修改负面清单
  taskNegativeItemPUT: {
    url: `/taskNegativeItem`,
    method: RequestEnum.PUT,
  } as AxiosRequestConfig,
  // 删除负面清单
  taskNegativeItemDEL: {
    url: `/taskNegativeItem`,
    method: RequestEnum.DELETE,
  } as AxiosRequestConfig,
  // 导入年度招生分数
  importEnrollmentAssement: {
    url: `/taskTargetMark/importEnrollmentAssement`,
    method: RequestEnum.POST,
    timeout: 60 * 1000,
  } as AxiosRequestConfig,
  // 校验码下载
  JiaoyandownloadFile: {
    url: `/taskCheckCode/anyTenant/downloadFile`,
    method: RequestEnum.POST,
    responseType: 'blob',
  } as AxiosRequestConfig,
  // 查看最终结果
  getFinalResultByYear: {
    url: `/taskTarget/getFinalResultByYear`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
};
export function uploadFile(
  params: UploadFileParams,
  onUploadProgress?: (progressEvent: AxiosProgressEvent) => void,
) {
  return defHttp.uploadFile<FileResultVO>(
    {
      url: `${ServicePrefixEnum.FILE}/taskTarget/importDetails`,
      onUploadProgress,
      // 60 s
      timeout: 60 * 1000,
    },
    params,
  );
}
// export const importQimo = (params: UploadFileParams) =>
//   defHttp.request<FileResultVO>({ ...Api.importQimo, params });
export const importQimoOr = () => defHttp.request<checklmportOV>({ ...Api.importQimoOr });
export const AllList = (params: PageParams<TaskInterimTargetPageQuery>) =>
  defHttp.request<PageResult<TaskTargetTypeResultVO>>({ ...Api.Page, params });
export const UploadgetDetailById = (params: UploadDetailById) =>
  defHttp.get<UploadDetailByIdOV>({ ...Api.UploadgetDetailById, params });
// pdf材料上传
export function UploadPdf(
  params: UploadFileParams,
  onUploadProgress: (progressEvent: AxiosProgressEvent) => void,
) {
  params.data = {
    bizType: 'INTERIM_TARGET',
    bucket: 'task-target-year',
    // bucket: 'interim-target',
    storageType: 'MIN_IO',
  };
  return defHttp.uploadFile<UploadPdfResult>(
    {
      url: `/file/anyone/upload`,
      // 60 s
      timeout: 60 * 1000,
      onUploadProgress,
    },
    params,
  );
}

export const NewUpload = (params: userUpload) =>
  defHttp.post<string[]>({ ...Api.NewUpload, params });
export const remove = (params: any[]) => defHttp.request<void>({ ...Api.del, params });
// export const ExpirationTime = (expirationTime: String[]) =>
//   defHttp.request<boolean>({ ...Api.expirationTime, params: { expirationTime } });
export const ExpirationTime = (params: expirationTime) =>
  defHttp.request<boolean>({ ...Api.expirationTime, params });
// 自评
export const taskInterimMarkPUT = (params: DefDictSaveVOs) =>
  defHttp.request<UploadDetailByIdOV>({ ...Api.taskInterimMarkPUT, params });
export const taskInterimMark = (params: DefDictSaveVO) =>
  defHttp.request<UploadDetailByIdOV>({ ...Api.taskInterimMark, params });
// 评分
export const taskInterimMarkPingfenPUT = (params: PingfenVOs) =>
  defHttp.request<UploadDetailByIdOV>({ ...Api.taskInterimMarkPUT, params });
export const taskInterimMarkPingfen = (params: PingfenVO) =>
  defHttp.request<UploadDetailByIdOV>({ ...Api.taskInterimMark, params });
export const checkIsCommit = () => defHttp.request<checklmportOVs>({ ...Api.checkIsCommit });
// export const commitConfirm = () => defHttp.request<checklmportOVs>({ ...Api.commitConfirm });
export const commitConfirm = (params: checklmportOVs) =>
  defHttp.request<UploadDetailByIdOV>({ ...Api.commitConfirm, params });
export const getAllCodeYears = () =>
  defHttp.request<getAllCodeYearsReault>({ ...Api.getAllCodeYears });
// export const generateTaskCheckCode = (params: generateTaskCheckCodes) =>
//   defHttp.request<generateTaskCheckCodeResult>({ ...Api.generateTaskCheckCode, params });
export const generateTaskCheckCode = (params: generateTaskCheckCodes) =>
  defHttp.request<generateTaskCheckCodeResult>({
    ...Api.generateTaskCheckCode,
    params,
  });
export const getTaskCheckCodeByYearAndType = (
  params: PageParams<getTaskCheckCodeByYearAndTypeos>,
) =>
  defHttp.request<PageResult<getTaskCheckCodeByYearAndTypeVO>>({
    ...Api.getTaskCheckCodeByYearAndType,
    params,
  });
export const getTaskFeatureContributeList = (params: getTaskFeatureContributeListos) =>
  defHttp.request<getTaskFeatureContributeListVO>({
    ...Api.getTaskFeatureContributeList,
    params,
  });
export const getAllFeatureContributeYears = () =>
  defHttp.request<getAllFeatureContributeYearsReault>({ ...Api.getAllFeatureContributeYears });
export const TsUpload = (params: TeseuserUpload) =>
  defHttp.post<string[]>({ ...Api.TsUpload, params });
export const TsUploadDelete = (params: any[]) =>
  defHttp.request<void>({ ...Api.TsUploadDelete, params });
export const taskFeatureContribute = (params: taskFeatureContributeOS) =>
  defHttp.request<void>({ ...Api.taskFeatureContribute, params });
export const taskFeatureContributeput = (params: taskFeatureContributeOS) =>
  defHttp.request<void>({ ...Api.taskFeatureContributeput, params });
export const IddownLoad = (year: string[] | number[]) =>
  defHttp.request<void>(
    { ...Api.down, params: qs.stringify({ year }, { arrayFormat: 'repeat' }) },
    { isReturnNativeResponse: true },
  );
// export const IddownLoad = (ids: string[] | number[]) =>
//   defHttp.request<void>(
//     { ...Api.down, params: qs.stringify({ ids }, { arrayFormat: 'repeat' }) },
//     { isReturnNativeResponse: true },
//   );

// 重大工作
export const getTaskTemporaryWorkList = (params: getTaskTemporaryWorkListos) =>
  defHttp.request<getTaskTemporaryWorkListVO>({
    ...Api.getTaskTemporaryWorkList,
    params,
  });
export const getAllTaskTemporaryWorkYears = () =>
  defHttp.request<getAllTaskTemporaryWorkYearsReault>({ ...Api.getAllTaskTemporaryWorkYears });
export const taskTemporaryWorkMaterial = (params: taskTemporaryWorkMaterialOS) =>
  defHttp.post<string[]>({ ...Api.taskTemporaryWorkMaterial, params });
export const ZDUploadDelete = (params: any[]) =>
  defHttp.request<void>({ ...Api.ZDUploadDelete, params });
export const taskTemporaryWork = (params: taskTemporaryWorkOS) =>
  defHttp.request<void>({ ...Api.taskTemporaryWork, params });
export const taskTemporaryWorkput = (params: taskTemporaryWorkputOS) =>
  defHttp.request<void>({ ...Api.taskTemporaryWorkput, params });
export const downloadFile = (year: string[] | number[]) =>
  defHttp.request<void>(
    { ...Api.downloadFile, params: qs.stringify({ year }, { arrayFormat: 'repeat' }) },
    { isReturnNativeResponse: true },
  );
export const getTaskNegativeItemList = (params: getTaskNegativeItemListos) =>
  defHttp.request<getTaskNegativeItemListVO>({
    ...Api.getTaskNegativeItemList,
    params,
  });
export const taskNegativeItemDEL = (params: any[]) =>
  defHttp.request<void>({ ...Api.taskNegativeItemDEL, params });
export const taskNegativeItem = (params: taskNegativeItemOS) =>
  defHttp.request<void>({ ...Api.taskNegativeItem, params });
export const taskNegativeItemPUT = (params: taskNegativeItemputOS) =>
  defHttp.request<void>({ ...Api.taskNegativeItemPUT, params });
export const getAllTaskNegativeItemYears = () =>
  defHttp.request<getAllTaskNegativeItemYearsReault>({ ...Api.getAllTaskNegativeItemYears });
export function importEnrollmentAssement(
  params: UploadFileParams,
  onUploadProgress?: (progressEvent: AxiosProgressEvent) => void,
) {
  return defHttp.uploadFile<FileResultVO>(
    {
      url: `/taskTargetMark/importEnrollmentAssement`,
      onUploadProgress,
      // 60 s
      timeout: 60 * 1000,
    },
    params,
  );
}
export const JiaoyandownloadFile = (year: string[] | number[], type: string[]) =>
  defHttp.request<void>(
    { ...Api.JiaoyandownloadFile, params: qs.stringify({ year, type }, { arrayFormat: 'repeat' }) },
    { isReturnNativeResponse: true },
  );
// export const getFinalResultByYearJX = (params: getFinalResultByYearJXOS) =>
//   defHttp.request<getFinalResultByYearJXVO>({ ...Api.getFinalResultByYear, params });
// export const getFinalResultByYear = (params: getFinalResultByYearOS) =>
//   defHttp.request<getFinalResultByYeartVO>({ ...Api.getFinalResultByYear, params });
export const getFinalResultByYearJX = (params: getFinalResultByYearJXOS) =>
  defHttp.request<getFinalResultByYearJXVO>({
    ...Api.getFinalResultByYear,
    params,
  });
export const getFinalResultByYear = (params: getFinalResultByYearOS) =>
  defHttp.request<getFinalResultByYeartVO>({
    ...Api.getFinalResultByYear,
    params,
  });
